package ljye.com.ljye.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.List;

import ljye.com.ljye.R;
import ljye.com.ljye.bean.Course_Details;

/**
 * Created by Administrator on 2016/12/28.
 * 明星老师横向滑动adapter
 */

public class Star_Teacher_GridViewAdapter extends BaseAdapter {
    Context context;
    List<Course_Details.DataBean.TeachersBean> list;

    public Star_Teacher_GridViewAdapter(Context context, List<Course_Details.DataBean.TeachersBean> list) {
        this.list = list;
        this.context = context;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    public void setContext(Context context) {
        this.context = context;
    }

    public void setList(List<Course_Details.DataBean.TeachersBean> list) {
        this.list = list;
    }

    @Override

    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        convertView = layoutInflater.inflate(R.layout.gridview_list_item, null);
        TextView tvCity = (TextView) convertView.findViewById(R.id.name);
        ImageView ItemImage = (ImageView) convertView.findViewById(R.id.ItemImage);

        String s = list.get(position).getName();
        tvCity.setText(s);
        Picasso.with(context)
                .load(list.get(position).getAvatar())
                .placeholder(R.drawable.ic_default_image)
                .into(ItemImage);
        return convertView;
    }
}

